<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>async</title>
  <style>
    * {
      margin: 0;
      padding: 0;
    }

    .cl1 {
      width: 100px;
    }

    .cl2 {
      width: 120%;
      border: 1px solid red;
      height: 20px;
    }
  </style>
</head>

<body>
  <div class="cl1">
    1
    <div class="cl2">2</div>
  </div>
  <script>
    // 使用async await  实现打印 1 2 3
    function fun1() {
      return new Promise((resolve, reject) => {
        setTimeout(() => {
          console.log(1);
          resolve()
        }, 3000)
      })
    }

    function fun2() {
      return new Promise((resolve, reject) => {
        setTimeout(() => {
          console.log(2);
          resolve()
        }, 2000)
      })
    }

    async function fun3() {
      await fun1()
      await fun2()
      console.log(3);
    }

    fun3()
  </script>
</body>

</html>